package com.cgly.medical.Util;

//import com.cgly.medical.util.EmailSchedulerTask;
import com.cgly.medical.util.MailClient;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @program: CGLY
 * @description:
 * @author: chen di
 * @create: 2022-08-23 15:11
 */


@RunWith(SpringJUnit4ClassRunner.class) //SpringJUnit4ClassRunner需要使用 JUnit 4.12 或更高版本
@SpringBootTest
public class Email {

    @Autowired
    MailClient mailClient;
//
//    @Autowired
//    EmailSchedulerTask emailSchedulerTask;

    @Test
    public void test1(){
        String to = "1326391014@qq.com";
        String sub = "我是帅哥！！！";
        String message = "你好啊！！";
        mailClient.sendMail(to,sub,message);
    }

    @Test
    @Scheduled(cron="* 45/1 * * * * ") //查看连接设置corn表达式
    public void test2() throws Exception{
        String to = "3212502557@qq.com";
        String sub = "我是帅哥！！！";
        String message = "你好啊！！";
        String filePathPdf = "D:\\文件\\时间\\cd\\简历\\2.0\\应聘：Java研发工程师-陈迪简历.pdf";
        String filePathExcel = null;
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        String emailContent = formatter.format(new Date())+" 日报表";
        mailClient.sendHtmlMail(to,formatter.format(new Date())+"日报表",emailContent, filePathExcel,filePathPdf);


        }

}